import {
  getPrintTypeList
} from "@/api/cabinet/cabinetPrint/index";
import { checkStr, uniqueKey } from "@/utils/judge";
import url from "@/axios/url";
const { mesUrl } = url();
let vm = null;
const sendThis = (_this) => {
  vm = _this;
};
export { sendThis };
// 列表头按钮配置
export const operateList = {
  data () {
    const _this = this;
    return {
      operateList: [
        {
          name: $i18n.t("common.add"),
          type: "primary",
          icon: "el-icon-circle-plus-outline",
          handleName: "add", // 点击时返回的标识
        },
        {
          name: $i18n.t("common.delete"),
          type: "danger",
          icon: "el-icon-delete",
          handleName: "deleteBatch", // 点击时返回的标识
          isMultiple: true,
        },
      ],
    };
  },
};
// 行末按钮配置
export const rowConfig = [
  {
    name: "打印",
    type: "primary",
    class: "row-btn-primary",
    handleName: "print", // 点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete", // 点击时返回的标识
  },
  // {
  //   name: "打印条形码",
  //   type: "primary",
  //   class: "row-btn-primary",
  //   handleName: "printBarCode", // 点击时返回的标识
  // }
];

// 搜索条件配置
export const searchConfig = {
  data () {
    const _this = this;
    return {
      searchConfig: {
        inline: true,
        formDesc: {
          vinCode: {
            type: "input",
            label: "车辆VIN码",
          },
          uwbShortCode: {
            type: "input",
            label: $i18n.t("keyClasp.UWBCode"),
          },
          operatorTimeSort: {
            type: "datetimerange",
            label: '打码时间',
            attrs: {
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              searchArrKey: ["printStartTime", "printEndTime"],
            },
          },
          printTypeCode: {
            type: "select",
            label: '打码类型',
            attrs: {
              filterable: true,
            },
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getPrintTypeList();
              return list.data.result;
            },
          },
        },
      },
    };
  },
};

var validatePass = (rule, value, callback) => {
  setTimeout(() => {
    if (!checkStr(value, "english-number")) {
      callback(new Error($i18n.t("mesProcess.rule8")));
    } else {
      callback();
    }
  }, 100);
};
// 新增/删除表单配置
export const formDescDialogMinxin = {
  data () {
    const self = this;
    return {
      formDescDialog: {
        span: 24,
        disabled: false,
        isShowSubmitBtn: true,
        rules: {
          uwbShortCode: [
            { validator: validatePass, trigger: ["change", "blur"] },
          ],
          printTypeCode: [
            { validator: validatePass, trigger: ["change", "blur"] },
          ],
        },
        formDesc: {
          uwbShortCode: {
            type: "input",
            label: 'UWB(短码)',
            layout: 12,
            required: true,
          },
          // uwbLongCode: {
          //   type: "input",
          //   label: 'UWB(长码)',
          //   layout: 12,
          //   required: true,
          //   disabled: true
          // },
          // vinCode: {
          //   type: "input",
          //   label: '车辆VIN码',
          //   layout: 12,
          //   required: true,
          //   disabled: true
          // },
          printTypeCode: {
            type: "select",
            label: '打码类型',
            layout: 12,
            required: true,
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getPrintTypeList()
              return list.data.result;
            },
          },
          
          // processTypeId: {
          //   type: "input",
          //   label: $i18n.t("cabinet.keyCode"),
          //   layout: 12,
          //   required: true,
          //   disabled: (d) => !!d.id,
          // },
          // processProperty: {
          //   type: "select",
          //   label: $i18n.t("cabinet.status"),
          //   layout: 12,
          //   required: true,
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getProcessPropertyList();
          //     return list.data.result;
          //   },
          // },
          // processCode: {
          //   type: "input",
          //   label: $i18n.t("cabinet.UWBCode"),
          //   layout: 12,
          //   required: true,
          // },
          // processName: {
          //   type: "input",
          //   label: $i18n.t("cabinet.VINCode"),
          //   layout: 12,
          //   required: true,
          // },
          // remark: {
          //   type: "textarea",
          //   label: $i18n.t("cabinet.remark"),
          //   layout: 12,
          //   required: false,
          // },
        },
      },
    };
  },
};

